package com.hedl.practice.diyJava.multithreading.thread_pool.thread_pool_test.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Task implements Runnable {

    private final String name;

    public String getName() {
        return name;
    }

    public Task(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        LocalDateTime ldt = LocalDateTime.now();
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        //System.out.println("start task " + name +"--时间--"+ldt);
        System.out.println("start task " + name +"--时间--"+dtf.format(ldt));
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        } finally {
            //System.out.println("end task " + name+"--时间--"+ldt);
            System.out.println("end task " + name+"--时间--"+dtf.format(ldt));
        }
    }
}
